import requests
import sys
import io
import time
import json
import base64
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8') #改变标准输出的默认编码

#登录后才能访问的网页
url = 'https://we.cqu.pt/api/mrdk/post_mrdk_info.php'

#浏览器登录后得到的cookie，也就是刚才复制的字符串,我们这里直接连通微重邮不需要cookie试试


#设置请求头
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.44",
    "CONTENT_TYPE":"application/json"
}
# 请求体

data = {
    # 手机号
    "lxdh":"13388888888",
    # 位置
    "xxdz":"重邮",
    "szdq":"四川省,成都市,武侯区",
    "jbsks":"否",
    "jbsfl":"否",
    "jbsbs":"否",
    "jbslt":"否",
    "jbsyt":"否",
    "jbsfx":"否",
    # name
    "name":"邓嘉文",
    # 学生号 
    "xh":"(2019214994)",
    "xb":"男",
    "latitude":30.626590320581055,
    "longitude":104.02320455214844,
    "locationBig":"中国,四川省,成都市,武侯区",
    "locationSmall":"重庆邮电大学",
    "hjsfly":"否",
    "ywjchblj":"无",
    "ywjcqzbl":"无",
    "xjzdywqzbl":"无",
    "twsfzc":"是",
    "ywytdzz":"无",
    "brsfqz":"无",
    "brsfys":"无",
    "jbs":"无",
    "sfyfy":"无",
    "fyjtgj":"无",
    "fyddsj":"无",
    "sfbgsq":"无",
    "sfjjgl":"无",
    "jjglqssj":"无",
    "wjjglmqqx":"无",
    "beizhu":"无",
    "qtycqk":"无",
    "mrdkkey":"6_Kf_Kk4",
    "timestamp":time.time()
}
# json格式
dataJson = json.dumps(data)    
# utf编码
utf8_data=dataJson.encode('utf-8')
# base64 加密
# base64_data=base64.b64encode(dataJson)
#在发送get请求时url + 请求头head + 请求体body
resp = requests.post(url, headers = headers,data = utf8_data)

# 打印返回的数据
print(resp.content.decode('utf-8'))

